﻿using DotNetExtensions.Core.Converters;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq;

namespace DotNetExtensions.Core.Helpers
{
    public class TypeProperty
    {
        public string ParentGuid { get; set; }
        public string Guid { get; set; }
        public string Name { get; set; }
        public object DefaultValue { get; set; }
        public string Description { get; set; }
        public bool IsArrayList { get; set; }
        public bool IsBasicType { get; set; }
        [JsonIgnore]
        public Type PropertyType { get; set; }
        public string PropertyTypeName => GetPropertyName();
        private string GetPropertyName()
        {
            if (IsArrayList) return $"List<{PropertyType?.Name ?? "T"}>";
            if (PropertyType != null && PropertyType.IsGenericType) //"ApiResult`1"
                return PropertyType.Name.Replace("`1","<T>");
            return PropertyType?.Name ?? "T";
        }
    }
    public class TypePropertyItem : TypeProperty
    {
        
    }
    public class TypePropertyTree : TypeProperty
    {
        public List<TypePropertyTree> InnerParameters { get; set; }
    }
}
